/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1629704075718_7688';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // mysql配置
  config.mysql = {
    // database configuration
    client: {
      // host
      host: 'localhost',
      // port
      port: '3306',
      // username
      user: 'fangquan',
      // password
      password: '123456',
      // database
      database: 'react_blog'
    }, 
    // load into app, default is open
    app: true,
    // load into agent, default is close
    agent: false
  }

  // 配置跨域（egg-cors)
  config.security = {
      csrf: {
        enable: false
      },
      domainWhiteList: [ '*' ]
  }

  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',

    // 如果只允许某个域名进行访问接口, 修改例如如下配置
    // origin: 'http://localhost:3000', // 只允许这个域进行访问接口
    credentials: true, // 开启认证, 允许Cook可以跨域( 可以用于同一个前后台跨域配置使用)
    // allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  }

  return {
    ...config,
    ...userConfig,
  };
};


